#include <string>
#include <algorithm>
#include <unordered_map>
using namespace std;
class Solution
{
public:
    bool checkInclusion(string s1, string s2)
    {
        unordered_map<int, int> u_map;
        for (auto e : s1)
        {
            u_map[e]++;
        }
        for (int i = 0, l = s1.size(); i + l < s2.size() + 1; i++)
        {
            unordered_map<int, int> tmp_map;
            for (int j = i; j < i + l; j++)
                tmp_map[s2[j]]++;
            if (u_map == tmp_map)
                return true;
        }
        return false;
    }
};